package com.entity;

import java.io.Serializable;
import javax.persistence.*;

import com.alibaba.fastjson.annotation.JSONField;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * The persistent class for the DELIVER database table.
 * 
 */
@Entity
@NamedQuery(name = "Deliver.findAll", query = "SELECT d FROM Deliver d")
public class Deliver implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@SequenceGenerator(name = "DELIVER_DEID_GENERATOR", sequenceName = "SEQ", initialValue = 1, allocationSize = 1)
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "DELIVER_DEID_GENERATOR")
	@Column(name = "DE_ID")
	private long deId;

	@Column(name = "DE_CONDITION")
	private String deCondition;

	@Column(name = "DE_NUM")
	private BigDecimal deNum;

	@Temporal(TemporalType.DATE)
	@JSONField(format = "yyyy-MM-dd")
	@Column(name = "DE_PLANTIME")
	private Date dePlantime;

	@Column(name = "DE_PRICE")
	private BigDecimal dePrice;

	@Column(name = "DE_REMARK")
	private String deRemark;

	@Column(name = "DE_REQUIRE")
	private String deRequire;

	@Column(name = "DE_WARN")
	private BigDecimal deWarn;

	// bi-directional many-to-one association to Order
	@ManyToOne
	@JoinColumn(name = "OR_ID")
	private Order order;

	// bi-directional many-to-one association to Deliverrecord
	@OneToMany(cascade = { CascadeType.REMOVE }, mappedBy = "deliver")
	
	private List<Deliverrecord> deliverrecords;

	@ManyToOne
	@JoinColumn(name = "PRO_ID")
	private Product product;

	public Product getProduct() {
		return product;
	}

	public void setProduct(Product product) {
		this.product = product;
	}

	@Transient
	private BigDecimal recordnum;

	public BigDecimal getRecordnum() {
		return recordnum;
	}

	public void setRecordnum(BigDecimal recordnum) {
		this.recordnum = recordnum;
	}

	@ManyToMany(mappedBy = "delivers")
	private List<Odo> odos;

	public List<Odo> getOdos() {
		return odos;
	}

	public void setOdos(List<Odo> odos) {
		this.odos = odos;
	}

	public Deliver() {
	}

	public long getDeId() {
		return this.deId;
	}

	public void setDeId(long deId) {
		this.deId = deId;
	}

	public String getDeCondition() {
		return this.deCondition;
	}

	public void setDeCondition(String deCondition) {
		this.deCondition = deCondition;
	}

	public BigDecimal getDeNum() {
		return this.deNum;
	}

	public void setDeNum(BigDecimal deNum) {
		this.deNum = deNum;
	}

	public Date getDePlantime() {
		return this.dePlantime;
	}

	public void setDePlantime(Date dePlantime) {
		this.dePlantime = dePlantime;
	}

	public BigDecimal getDePrice() {
		return this.dePrice;
	}

	public void setDePrice(BigDecimal dePrice) {
		this.dePrice = dePrice;
	}

	public String getDeRemark() {
		return this.deRemark;
	}

	public void setDeRemark(String deRemark) {
		this.deRemark = deRemark;
	}

	public String getDeRequire() {
		return this.deRequire;
	}

	public void setDeRequire(String deRequire) {
		this.deRequire = deRequire;
	}

	public BigDecimal getDeWarn() {
		return this.deWarn;
	}

	public void setDeWarn(BigDecimal deWarn) {
		this.deWarn = deWarn;
	}

	public Order getOrder() {
		return this.order;
	}

	public void setOrder(Order order) {
		this.order = order;
	}

	public List<Deliverrecord> getDeliverrecords() {
		return this.deliverrecords;
	}

	public void setDeliverrecords(List<Deliverrecord> deliverrecords) {
		this.deliverrecords = deliverrecords;
	}

	public Deliverrecord addDeliverrecord(Deliverrecord deliverrecord) {
		getDeliverrecords().add(deliverrecord);
		deliverrecord.setDeliver(this);

		return deliverrecord;
	}

	public Deliverrecord removeDeliverrecord(Deliverrecord deliverrecord) {
		getDeliverrecords().remove(deliverrecord);
		deliverrecord.setDeliver(null);

		return deliverrecord;
	}

	@Override
	public String toString() {
		return "Deliver [deId=" + deId + ", deCondition=" + deCondition + ", deNum=" + deNum + ", dePlantime="
				+ dePlantime + ", dePrice=" + dePrice + ", deRemark=" + deRemark + ", deRequire=" + deRequire
				+ ", deWarn=" + deWarn + ", order=" + order + ", deliverrecords=" + deliverrecords + ", product="
				+ product + ", recordnum=" + recordnum + ", odos=" + odos + "]";
	}

}